<template>
	<!-- 猎聘 -->
	<view class="bigbox">
		<!-- 头部盒子 -->
		<view class="headerbox flex mt40">
			<!-- 左侧 -->
			<view class="headerbox-l" @click="$jump('/pages/home/BlueCollar/jobList/jobList?tit=招聘信息&type='+type)">
				<image src="/static/img/index/3liepin-zhaopin.png" class="w370 h205"></image>
			</view>
			<!-- 右侧 -->
			<!-- <view class="headerbox-r" @click="$jump('/pages/home/recruit/vipJob/vipJob?type='+type)"> -->
			<view class="headerbox-r" @click="gotoVipJob">
				<image src="/static/img/index/3liepin-VIP.png" class="w370 h205"></image>
			</view>
		</view>
		<!-- /头部盒子 -->
		<!-- banner主体部分 -->
		<view>
			<!-- banner头部 -->
			<view class="bannertit flex col-center h40">
				<image src="/static/img/index/3liepin-hot.png" class="w52 h62 mt20 mr20"></image>
				<text class="tit">热门推荐</text>
			</view>
			<!-- /banner头部 -->

			<!-- 职位列表组件 -->
			<u-empty text="暂无热门推荐" marginTop="100" v-if="!list.length"></u-empty>
			<view class="" v-for="(item,index) in list" :key="index">
				<blueJobList :data="item" />
			</view>
			<!-- /职位列表组件 -->
		</view>
		<!-- /banner主体部分 -->
		
		<!-- 提示卡通会员的弹层 -->
		<u-popup v-model="showModel" mode='center'>
			<view class="popbox flex col-center row-column row-between pl28 pr28">
				<image src="~@/static/img/index/3liepin-pop.png" class="w160 h200"></image>
				<view class="">
					您还不是VIP会员，快去开通吧~
				</view>
				<view class="popbtn flex h120 pt26 pb26 col-center">
						<view class="popbtnleft flex1 text-center" @click="showModel=false">
							取消
						</view>
						<view class="popbtnright VIPInfoTit flex1 text-center" @click="$jump('/pages/my/VIP/VIP')">
							去开通
						</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import blueJobList from '@/components/blueJobList.vue'
	export default {
		name:'recruit',
		components: {
			blueJobList
		},
		data() {
			return {
				showModel: false,
				list: [],
				page: 1,
				type: '', // 实习 type==3
				name: '',
				recruit_level:uni.getStorageSync('userInfo').recruit_level,
				internship_level:uni.getStorageSync('userInfo').internship_level
			};
		},
		onLoad(e) {
			if (e.type) {
				this.type = e.type
			}
			if (e.tit) {
				uni.setNavigationBarTitle({
					title: e.tit
				})
			}
			this.reindex()
		},
		onReachBottom() {
			this.page++
			this.reindex()
		},
		methods: {
			gotoVipJob() {
				if(this.type!=3) {
					// console.log(111)
					if(this.recruit_level==0) {
						this.showModel=true
						// uni.showModal({
						// 	content:'您还不是会员,快去开通吧',
						// 	confirmText:'去开通',
						// 	confirmColor:'#FD1D4D',
						// 	  success: function (res) {
						// 	        if (res.confirm) {
						// 	            console.log('用户点击确定');
						// 				uni.navigateTo({
						// 					url:'/pages/my/VIP/VIP'
						// 				})
						// 	        } else if (res.cancel) {
						// 	            console.log('用户点击取消');
						// 	        }
						// 	    }
						// })
					}else {
						// console.log(222)
						uni.navigateTo({
							url: '/pages/home/recruit/vipJob/vipJob?type='+this.type
						})
					}
				}else if(this.type==3) {
					if(this.internship_level==0) {
						this.showModel=true
						// uni.showModal({
						// 	content:'您还不是会员,快去开通吧',
						// 	confirmText:'去开通',
						// 	confirmColor:'#FD1D4D',
						// 	  success: function (res) {
						// 	        if (res.confirm) {
						// 	            console.log('用户点击确定');
						// 				uni.navigateTo({
						// 					url:'/pages/my/VIP/VIP'
						// 				})
						// 	        } else if (res.cancel) {
						// 	            console.log('用户点击取消');
						// 	        }
						// 	    }
						// })
					}else {
						// console.log(222)
						uni.navigateTo({
							url: '/pages/home/recruit/vipJob/vipJob?type='+this.type
						})
					}
				}
				
			},
			reindex() { //蓝领热门推荐
				let data = {
					name: this.name,
					page: 1,
					size: this.page * 10,
					state: 2
				}
				let api
				if (this.type == 1) {
					api = 'reindex'
				} else if (this.type == 3) {
					api = 'Internships'
				}
				this.$api[api](data).then(res => {
					this.list = res.data
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		height: auto;
	}

	.bannertit {
		font-size: 34rpx;
		color: #0C162E;
		line-height: 40rpx;
	}
	.popbox {
		width: 700rpx;
		height: 460rpx;
		background-color: #FFFFFF;
		box-shadow: 0px 6rpx 26prx 0px rgba(70, 74, 90, 0.28);
		border-radius: 14rpx;
	}
	.popbtn {
		width: 100%;
		border-top: 2rpx solid #D2DEEB;
		.popbtnleft,{
			border-right:2rpx solid #D2DEEB ;
			font-size: 30rpx;
			color: #0C162E;
		}
		.popbtnright {
			font-size: 30rpx;
			color: #FD1D4D;
		}
	}
</style>
